package com.gzhryc.shared_device.oem.code.place.dao.models;

import com.gzhryc.common.StringTools;
import com.gzhryc.common.json.JsonTools;
import com.gzhryc.jdbc.annotaion.Join;
import com.gzhryc.jdbc.annotaion.JoinField;
import com.gzhryc.shared_device.oem.code.business.EBusinessType;
import com.gzhryc.shared_device.oem.code.place.dao.db.PlacePhysicalStore;
import com.gzhryc.shared_device.oem.code.place.dao.db.PlaceProfitUser;

public class PlacePhysicalStoreUser extends PlaceProfitUser {

    @Join(fromField = "place_id")
    private PlacePhysicalStore place;

    @JoinField(name="name",fromField = "place_user_id",toTable = "user_info")
    private String placeUserName;

    public PlacePhysicalStore getPlace() {
        return place;
    }

    public void setPlace(PlacePhysicalStore place) {
        this.place = place;
    }

    public String getPlaceUserName() {
        return placeUserName;
    }

    public void setPlaceUserName(String placeUserName) {
        this.placeUserName = placeUserName;
    }

    public String getIncomeRatioInfo(){
        if(StringTools.isNotBlank(incomeRatioContent)){
            IncomeRatioContent ratioContent = JsonTools.fromJson(incomeRatioContent,IncomeRatioContent.class);
            if(ratioContent != null && ratioContent.getItems() != null && ratioContent.getItems().size() > 0){
                String result = "";
                for(IncomeRatioContent.Item item : ratioContent.getItems()){
                    result = result + "," + EBusinessType.note(item.getBusinessType()) + ":" + item.getIncomeRatio() + "%";
                }
                return result.substring(1);
            }
        }
        return "";
    }
}
